# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Gergely Imreh <imrehgATgmailDOTcom>

pkgname=libx86emu
pkgver=3.5
pkgrel=3
pkgdesc='x86 emulation library'
arch=(loong64 x86_64)
url='https://github.com/wfeldt/libx86emu'
license=(BSD)
makedepends=(git setconf)
source=("git+$url#commit=41aaa2f246d362f6d7dea262052a43141743ead2") # tag: 3.5
b2sums=('SKIP')

prepare() {
  sed -i 's/-shared -Wl/-shared '"$LDFLAGS"'/g' $pkgname/Makefile
  setconf $pkgname/Makefile \
    CFLAGS="$CFLAGS -shared -fPIC -fvisibility=hidden -fomit-frame-pointer -w"
}

build() {
  make -C $pkgname LIBDIR=/usr/lib
}

package() {
  make -C $pkgname LIBDIR=/usr/lib DESTDIR="$pkgdir" install
  install -Dm644 $pkgname/LICENSE \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
